<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery.min.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
              $.ajax({
              url:"/user/testAjax",
              data:'{"username":"zhangsan","password":"123","age":12}',
                  contentType:"application/json;charset=UTF-8",
              dataType:"json",
                  type:"post",
                  success:function (data) {
                         alert(data)
                      alert(data.username)
                      alert(data.password)
                      alert(data.age)
                  }
              });
            })
        })
    </script>
</head>
<body>
 <button id="btn">发送ajax请求</button>
</body>
</html>
